#include "functionpointer.h"
#include <iostream>

using namespace std;


FunctionPointer::FunctionPointer()
{

}

int FunctionPointer::res(int a,int b)
{
   return (a-b);
}
int FunctionPointer::sum(int a,int b)
{
    return (a+b);
}

int main()
{
	int operacion;

	int primero;
	int segundo;

	cout << "suma (1)--- resta (2)" << endl;
	cout << "use 1 y 2 para selecionar la operacion:" << endl;
	cin >> operacion;

	cout << "primer numero a operar=" << endl;
	cin >> primero;

	cout << "segundo numero a operar=" << endl;
	cin >> segundo;

    FunctionPointer f;

	if(operacion == 1)
	{
		f.pointer = &FunctionPointer::sum;
		cout << primero << "+" << segundo << "=" <<(f.*(f.pointer))(primero,segundo) << endl;
	}
	else if (operacion == 2)
	{
		f.pointer = &FunctionPointer::res;
		cout << primero << "-" << segundo << "=" <<(f.*(f.pointer))(primero,segundo) << endl;
	}

}
